import { _decorator, Component, Node, Sprite, SpriteFrame, UITransform } from 'cc';
import { TILE_TYPE_ENUM } from '../scripts/enums';
const { ccclass, property } = _decorator;

@ccclass('TileManager')
export class TileManager extends Component {
    _type: TILE_TYPE_ENUM;
    _sprite: any;

    init(type: TILE_TYPE_ENUM, sprite_frame: SpriteFrame) {
        this._type = type;

        this._sprite = this.addComponent(Sprite); // 这个组件类添加一个精灵
        this._sprite.spriteFrame = sprite_frame; // 设置背景
    }

    uiTransformChange(w: number, h: number, type: any = Sprite.Type.SIMPLE) {
        this._sprite.getComponent(UITransform).setContentSize(w, h);
        this._sprite.type = type;
    }
}
